import { NgModule, ModuleWithProviders } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { RequestService } from './service/request.service';
import { API_URL_TOKEN } from './request.token';

@NgModule({
  imports: [
    CommonModule
  ],
  declarations: []
})
export class RequestModule {
  public static forRoot(apiUrl: string): ModuleWithProviders {
    console.log(121212121343545);
    return {
      ngModule: RequestModule,
      providers: [
        { provide: HTTP_INTERCEPTORS, useClass: RequestService, multi: true },
        { provide: API_URL_TOKEN, useValue: apiUrl }
      ]
    };
  }
}
